﻿
using System.Collections.Generic;
using System.Data;
using System;
namespace ZHDJ.MobileInterface
{
    public partial class GetMediaNewsDetail : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            MediaNewsDetailOutParam result = new MediaNewsDetailOutParam();
            MediaNewsDetailInParam param = new MediaNewsDetailInParam();
            string logMsg = "";
            bool isFlag = true;
                 
            try
            {
                param = inParam as MediaNewsDetailInParam;
                if (string.IsNullOrEmpty(param.MessageID))
                {
                    result.code = "0";
                    result.desc = "留言ID不能为空";

                    isFlag = false;
                } 

                if(isFlag)
                {
                    DataSet ds = InterfaceHelper.GetMediaNewsDetail(param.MessageID);

                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        result.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                        result.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                        result.CreateTime = ds.Tables[0].Rows[0]["CreateTime"].ToString();
                        result.phone = ds.Tables[0].Rows[0]["phone"].ToString();
                        result.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                        result.username = ds.Tables[0].Rows[0]["username"].ToString();

                        if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ReplyUser"].ToString()))
                        {
                            result.Reply_info = new Reply_info();
                            result.Reply_info.ReplyContent = ds.Tables[0].Rows[0]["ReplyContent"].ToString();
                            result.Reply_info.ReplyerTime = Convert.ToString(ds.Tables[0].Rows[0]["ReplyerTime"]);
                            result.Reply_info.ReplyUser = Convert.ToString(ds.Tables[0].Rows[0]["ReplyUser"]);
                        }
                    } 
                }
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员"; 
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode +"-GetMediaNewsDetail", SerializeHelper.JsonSerializer<MediaNewsDetailInParam>(param), logMsg); 
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<MediaNewsDetailInParam, MediaNewsDetailOutParam>();
            else
                SafeProcessRequest<MediaNewsDetailInParam, MediaNewsDetailOutParam>();
        }
    }

    #region 请求参数
    public class MediaNewsDetailInParam
    { 
        /// <summary>
        /// 必填		留言IDD
        /// </summary>
        public string MessageID
        { get; set; } 
    }
    #endregion

    #region 结果参数
    public class MediaNewsDetailOutParam
    {
        public MediaNewsDetailOutParam()
        {
            code = "1";
            desc = "操作成功"; 
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        ///	留言标题
        /// </summary>
        public string Title
        { get; set; }

        /// <summary>
        ///	留言内容
        /// </summary>
        public string Content
        { get; set; }

        /// <summary>
        ///	留言者姓名
        /// </summary>
        public string username
        { get; set; }

        /// <summary>
        ///	留言时间
        /// </summary>
        public string CreateTime
        { get; set; }

        /// <summary>
        ///	联系方式
        /// </summary>
        public string phone
        { get; set; }

        /// <summary>
        ///	联系地址
        /// </summary>
        public string Address
        { get; set; }

        /// <summary>
        ///  
        /// </summary>
        public Reply_info Reply_info
        { get; set; }
    }   

    /// <summary>
    /// 
    /// </summary>
    public class Reply_info
    {
        /// <summary>
        /// 	回复内容
        /// </summary>
        public string ReplyContent
        { get; set; } 
        /// <summary>
        /// 	回复时间
        /// </summary>
        public string ReplyerTime
        { get; set; } 
        /// <summary>
        ///	回复人名称 
        /// </summary>
        public string ReplyUser
        { get; set; } 
    }
    #endregion 
}